
<link rel="stylesheet" href="jquery/easyui/themes/default/easyui.css">
<link rel="stylesheet" href="jquery/easyui/themes/icon.css">
<body>
<div style="width: 100%;height: 98%">
    <table id="easyui_datagrid_source_fac" style="border:1px solid blue" >

    </table>
</div>


<script src="https://upload.shinehao.com.cn/20180816150739jquery-1.8.3.min.js"></script>
<script src="https://upload.shinehao.com.cn/20180816145716jquery.easyui.min.js"></script>
<script src="https://upload.shinehao.com.cn/20180816151727easyui-lang-zh_CN.js"></script>
<script>
var cpLock = false;
$(function(){
    $("body").bind("click",function(){
        $('#easyui_datagrid_source_fac').combogrid("showPanel");
    })
    $('#easyui_datagrid_source_fac').combogrid({
        mode:"remote",
        url:window.parent.serverUrl+"/createOrder/getArtsList",
        queryParams: {
            material_type: window.parent.Util_artsEvent.material_type
        },
        idField: 'materialType',
        textField: 'technology',
        columns:[[
            {field:'materialType',title:'物料类型'},
            {field:'technology',title:'工艺'}
        ]],
        height:"10%",
        nowrap: false,
        width:"80%",
        panelWidth:"100%",
        panelHeight:"88%",
        //rownumbers:true,
        fitColumns:true,
        pagination:false,
        //pageSize: 10,
        pageList: [10,20,50,100],
        layout:['links'],
        loadMsg:"加载中,请等待...",
        singleSelect:true,
        align:"center",
        //toolbar: '#easyui_datagrid_source_fac_tool',
        loadFilter: function(data){
          return data.data;  
        },
        keyHandler: {
            enter: function(e){
                var rows = $('#easyui_datagrid_source_fac').combogrid('grid').datagrid('getData').rows;	// get datagrid object
                filldata("",$('#easyui_datagrid_source_fac').combogrid("getText"))
                $('#easyui_datagrid_source_fac').combogrid("showPanel");
            },
            query: function (q) {
            	setTimeout(function(){
	            	if(!cpLock){
	                	$('#easyui_datagrid_source_fac').combogrid("grid").datagrid("reload", {
	                        material_type: window.parent.Util_artsEvent.material_type,
	                        'q': q,
	                    });
	                    $('#easyui_datagrid_source_fac').combogrid("setValue",q);
	                }
            	},0);
            },
            up: function (e) {
                
            },
            down: function (e) {
                
            }
        },
        onLoadSuccess:function(data){
        	/* $(".datagrid-pager").pagination({layout:['links']}); */
            if(data.total > 0) {
                $("input[type='text']").focus();
                return;
            }  
            //$(this).datagrid('appendRow', { color: '<div style="text-align:center;color:red">没有相关记录！</div>' }).datagrid('mergeCells', { index: 0, field: 'color', colspan: 3});  
            $("input[type='text']").focus();
            $('#easyui_datagrid_source_fac').combogrid("showPanel");
            
            $("input[type='text']").on('compositionstart', function () {
                cpLock = true;
            });
            $("input[type='text']").on('compositionend', function () {
                cpLock = false;
            });
        },
        /*onSelect:function(index,row){
            console.info(row);
            var self = $(window.parent.document).find("["+dom.split(":")[0]+"='"+dom.split(":")[1]+"']");
            //console.info("myid:"+$(self).attr("myid")+":"+$(self).length+":"+"'"+dom.split(":")[0]+"'");
            //console.info("id:"+$(self).attr("id")+":"+$(self).length+":"+"'"+dom.split(":")[0]+"'");
            //console.info($(self).attr("'"+dom.split(":")[0]+"'"));
            //物料代码 色号 颜色描述 规格 填充
            
            $("input[type='text']").focus();
            $('#easyui_datagrid_source_fac').combogrid("showPanel");
        },*/
        onClickRow:function(index,row){
            filldata(row,"");
            $("input[type='text']").focus();
            $('#easyui_datagrid_source_fac').combogrid("showPanel");
        }
    });
    $('#easyui_datagrid_source_fac').combogrid("showPanel");
    $("input[type='text']").focus();
})
    
function filldata(data,text){
    if(data!=""){
    	window.parent.Util_artsEvent.setContent(data.technology);
    }
    if(data==""){
    	window.parent.Util_artsEvent.setContent(text);
    }
}

</script>
</body>


























